package com.meessiom.train.crm.course.service;
import com.meessiom.train.crm.course.model.Course;
import com.meessiom.train.crm.student.model.Student;
import com.meessiom.train.crm.course.repository.CourseRepository;
import com.meessiom.train.crm.student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseService {
    @Autowired
    private CourseRepository courseRepository;

    private CourseService courseService;

    public List<Course> getAllCourse(){

        return courseRepository.findAll();
    }
    public Course create(Course course) {
        return courseRepository.save(course);
    }

    public Course getCourseById(long id) {
        return  courseRepository.getById(id);
    }

    public void deleteCourse(long id) {

        Course c = courseRepository.getById(id);

        if( null != c )
            courseRepository.delete(c);

    }

}
